package hhm.android.machine

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import hhm.android.base.adapter.HBaseAdapter
import hhm.android.library.utils.OnMultiClickListener
import siau.android.base.MyBlueToothBean

class BindThreeAdapter(list: ArrayList<MyBlueToothBean>, var listener: OnMultiClickListener) : HBaseAdapter<BindThreeViewHolder, MyBlueToothBean>(list) {
    override fun bindData(holder: BindThreeViewHolder, bean: MyBlueToothBean, position: Int) {
        if (bean.deviceType == 1) {
            holder.iv.setImageResource(R.mipmap.weight_machine_model)
        } else if (bean.deviceType == 2) {
            holder.iv.setImageResource(R.mipmap.height_machine_model)
        } else if (bean.deviceType == 3) {
            holder.iv.setImageResource(R.mipmap.toothbrush_machine_model)
        }
        holder.tv.text = bean.bluetoothDevice.name ?: "未知名称" + "    " + bean.bluetoothDevice.address
        holder.itemView.setOnClickListener(object : OnMultiClickListener() {
            override fun onMultiClick(v: View?) {
                v?.tag = bean
                listener.onMultiClick(v)
            }
        })
    }

    override fun bindView(parent: ViewGroup, viewType: Int): BindThreeViewHolder {
        val v = LayoutInflater.from(parent.context).inflate(R.layout.item_bind_three, parent, false)
        return BindThreeViewHolder(v)
    }
}